package com.shuiyu.cloud.controller;


import com.shuiyu.cloud.entities.CommonResult;
import com.shuiyu.cloud.entities.Payment;
import com.shuiyu.cloud.service.PaymentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author rjw
 * <p>Description:   </p>
 * @ClassName PaymentController
 * @time 2021/7/13 17:23
 */
@RestController
@Slf4j
public class PaymentController {

    @Resource
    PaymentService paymentService;

    @Value("${server.port}")
    private String serverPort;


    @GetMapping("payment/get/{id}")
    public CommonResult query(@PathVariable("id")Long id){
        Payment payment = paymentService.getPaymentById(id);
        return new CommonResult(200,"ok,serverport"+serverPort,payment);

    }
    @PostMapping("/add")
    public CommonResult add(@RequestBody Payment payment){
        paymentService.create(payment);
        log.info(payment.getId().toString());
        System.out.println("payment = " + payment);
        return new CommonResult(200,"ok,serverport"+serverPort,payment.getId());
    }



}
